#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__author__ = "Administrator"
__name__="applys"
__date__="2016/9/19"
__time__="10:23"
"""
'''
# 执行没有带参数的方法：
def say():
    print 'say hello'

apply(say)
'''

'''
# 执行只带元祖类型参数的方法：
def say(a,b):
    print a, b

apply(say,('hello','tomcat'))
'''
# 执行带关键字参数的方法:
# 形参名称a b 必须上下一致。
def say(a=1,b=2):
    print a,b


apply(say,(),{'a':5,'b':6})

kw = {'a':'hello','b':'tomcat'}
apply(say,(),kw)

def haha(**kw):
    apply(say,(),kw)

haha(a='hello',b='nginx')

# apply 与call方法结合使用
class f(object):
    def __init__(self,func,args):
        self.func = func
        self.args = args
    def __call__(self):
        apply(self.func,self.args)

def loop(a,b):
    print a,b
f(loop,('hello','apache'))()